Thực đơn
Giao thức truyền thông điệp Chương trình mẫuDưới đây là chương trình "Hello World" dùng MPI trong ngôn ngữ C. Chúng ta gửi thông điệp hello
đến mỗi chip, chạy như bình thường, gửi kết quả trở lại chip chính, cuối cùng in ra.
/* Test of MPI */ #include <mpi.h> #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char idstr[32]; char buff[128]; int numprocs; int myid; int i; MPI_Status stat; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); if(myid == 0) { printf("We have %d processors\n", numprocs); for(i=1;i<numprocs;i++) { sprintf(buff, "Hello %d! ", i); MPI_Send(buff, 128, MPI_CHAR, i, 0, MPI_COMM_WORLD); } for(i=1;i<numprocs;i++) { MPI_Recv(buff, 128, MPI_CHAR, i, 0, MPI_COMM_WORLD, &stat); printf("%s\n", buff); } } else { MPI_Recv(buff, 128, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &stat); sprintf(idstr, "Processor %d ", myid); strcat(buff, idstr); strcat(buff, "reporting for duty\n"); MPI_Send(buff, 128, MPI_CHAR, 0, 0, MPI_COMM_WORLD); } MPI_Finalize(); return 0; }
Thực đơn
Giao thức truyền thông điệp Chương trình mẫuLiên quan
Giao Giao thừa Giao tiếp phi ngôn ngữ Giao Chỉ Giao Linh (ca sĩ) Giao tiếp Giao phối ở động vật Giao hưởng số 5 (Beethoven) Giao thông công cộng Giao diện giọng nói người dùngTài liệu tham khảo
WikiPedia: Giao thức truyền thông điệp http://www.clusterresources.com/moab http://www.hp.com/go/mpi http://www.myri.com/scs/download-mpichgm.html http://www.myri.com/scs/download-mpichmx.html http://www.scali.com/ http://www.ll.mit.edu/MatlabMPI/ http://nowlab.cse.ohio-state.edu/projects/mpi-iba/ http://exodus.physics.ucla.edu/appleseed/dev/devel... http://www.cs.usfca.edu/mpi/ http://www-unix.mcs.anl.gov/mpi/mpich/